import { createWebHashHistory, createRouter } from 'vue-router'
import Home from '../views/Home.vue'
import Doc from '../views/Doc.vue'
import SwitchDemo from '../components/SwitchDemo.vue'
import ButtonDemo from '../components/Button/ButtonDemo.vue'
import DialogDemo from '../components/DialogDemo.vue'
import TabsDemo from '../components/TabsDemo.vue'
import InputDemp from '../components/Input/InputDemo.vue'

import MarkDown from '../views/MarkDown.vue'
import Intro from '../markdown/intro.md'
import GetStarted from '../markdown/getstarted.md'
import Install from '../markdown/install.md'
import { h } from 'vue'

const mdRender = (content: string) => h(MarkDown, { content, key: content });

const history = createWebHashHistory()
export const router = createRouter({
    history: history,
    routes: [
        { path: "", component: Home },
        {
            path: "/doc", component: Doc, children: [
                { path: "", redirect: '/doc/intro' },
                {
                    path: 'intro',
                    name: '介绍',
                    component: mdRender(Intro),
                    meta: {
                        prev: '',
                        next: '安装',
                    },
                },
                {
                    path: 'install',
                    name: '安装',
                    component: mdRender(Install),
                    meta: {
                        prev: '介绍',
                        next: '开始',
                    },
                },
                {
                    path: 'get-started',
                    name: '开始',
                    component: mdRender(GetStarted),
                    meta: {
                        prev: '安装',
                    },
                },
                { path: "switch", component: SwitchDemo },
                { path: "button", component: ButtonDemo },
                { path: "dialog", component: DialogDemo },
                { path: "tabs", component: TabsDemo },
                { path: "input", component: InputDemp },
            ]
        }
    ]
})